<?php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');

/**
 * Account Controller
 * @package  CMS
 * @author Vui Nguyen - 09/04/2013 
 * @link http://joomlavui.info
 */
class User extends CI_Controller {
    
    function __construct() {
        parent::__construct();
        $this->load->library('session');
        $this->load->library('smarty3');
        $this->smarty			= new CI_Smarty3();
        
        $this->load->model('db_user_model');
        $this->db_user_model		= new db_user_model();
        $this->load->model('db_game_model');
        $this->db_game_model = new db_game_model();
        $this->load->model('db_item_model');
        $this->db_item_model = new db_item_model();
        $this->load->model('db_logs_model');
        $this->db_logs_model = new db_logs_model();
        
        require_once APPPATH . '../library/captcha/securimage.php';
    }

    //---------------------------------------------------------------------
    // ------------------------- HOME -------------------------------------
    function index() {
        $user = $this->session->userdata('user_info');
        if(!$user)
        {
            redirect('home');
        }
        
        //get game with status=1
        $data['game'] = $this->db_game_model->getAllGame();
        //lấy item đã hợp lệ hoàn toàn
        $data['item'] = $this->db_item_model->getItem(array("username"=>$user[0]->username,"status"=>1));
        //lấy item đang chờ xác nhận (gửi/rút) từ phía sàn
        $strQuery = "(username='".$user[0]->username."' and trans_order=1 and confirm_order<>0)";
        $data['item-pending'] = $this->db_item_model->getItembySqlStr($strQuery);
        //$data['item-pending'] = $this->db_logs_model->getLogs(array("username1"=>$user[0]->username));
        
        $this->smarty->assign(array("user_info"=>$user,"data"=>$data,"db_game_model"=>$this->db_game_model));
        $this->smarty->view('template/frontend/user/content','content');
        $this->smarty->display('template/frontend/home');
    }
}

/* End of file account.php */
/* Location: ./application/controllers/account.php */